package com.yang.booking.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yang.booking.pojo.Student;
import com.yang.booking.pojo.StudentScore;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StudentMapper extends BaseMapper<Student> {

    @Select("select st.*, c.c_id, c.c_name, s.s_score from Student st inner join Score s on s.s_id = st.s_id inner join Course c on c.c_id = s.c_id")
    List<StudentScore> queryScore();

    @Select("select st.* from Student st inner join Score s on s.s_id = st.s_id inner join Course c on c.c_id = s.c_id where s.s_score = #{score}")
    QueryWrapper<Student> addCourse(String score);

    @Select("select st.* from Student st inner join Score s on s.s_id = st.s_id inner join Course c on c.c_id = s.c_id where c.c_id = #{cId}")
    List<Student> addScore(String cId);
}

